<?php
namespace Client;
/**
 * Created by PhpStorm.
 * User: 554665488
 * Date: 2018-6-27
 * Time: 20:47
 * @description: 客户端请求服务中心 注册服务
 * @Author: yfl
 * @QQ 554665488
 */
class HttpClient
{
    protected $client;

    public function __construct($ip, $port)
    {
        $client = new \Swoole\Http\Client($ip, $port);
        $this->client = $client;
//        $client->setHeaders([
//            'Accept'=>'text/html,application/xhtml+xml,application/xml',
//            'Accept-Encoding'=>'gzip'
//        ]);
    }


    //异步webSocket 发送数据
    public function asyncWebSocket($callback, $path = '/')
    {
        $this->client->on('message', function ($cli, $frame) {

        });
        $this->client->upgrade($path, $callback);

    }
}